package cardCollections;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;

import cards.Ace;
import cards.Card;
import cards.Jack;
import cards.King;
import cards.Queen;

/**
 * 
 * @author akazero1
 * 
 */
public class FixedDeck {
	private List<Card> fixedDeck = new ArrayList<Card>();

	/**
	 * requires nothing
	 * 
	 * @return this.ficcedDeck() ensures: nothing
	 */
	public List<Card> getFixedDeck() {
		return fixedDeck;
	}

	/**
	 * finds and returns a card based on it's string
	 * 
	 * @param cardString
	 *            the string representation of the card
	 * @return the card
	 */
	public Card getCard(String cardString) {
		for (Card c : fixedDeck) {
			if (c.toString().equals(cardString))
				return c;
		}
		return null;
	}

	/**
	 * returns a hand with the cards represented by the string
	 * 
	 * @param cardsString
	 *            the string of cards to make into a hand
	 * @return the hand with the specified cards
	 */
	public Hand getCards(String cardsString) {
		String[] temp = cardsString.split("\n");
		Hand tempHand = new Hand();
		for (String dude : temp) {
			tempHand.AddCard((getCard(dude)));
		}
		return tempHand;
	}

	/**
	 * Requires: nothing Creates a new deck of 52 cards
	 * 
	 * @throws IOException
	 * 
	 */
	public FixedDeck() throws IOException {

		BufferedImage img = ImageIO.read(new File("Images\\c2.gif"));
		fixedDeck.add(new Card(2, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c3.gif"));
		fixedDeck.add(new Card(3, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c4.gif"));
		fixedDeck.add(new Card(4, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c5.gif"));
		fixedDeck.add(new Card(5, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c6.gif"));
		fixedDeck.add(new Card(6, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c7.gif"));
		fixedDeck.add(new Card(7, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c8.gif"));
		fixedDeck.add(new Card(8, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c9.gif"));
		fixedDeck.add(new Card(9, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c10.gif"));
		fixedDeck.add(new Card(10, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\cj.gif"));
		fixedDeck.add(new Jack(10, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\cq.gif"));
		fixedDeck.add(new Queen(10, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\ck.gif"));
		fixedDeck.add(new King(10, "Clubs", 1, img));
		img = ImageIO.read(new File("Images\\c1.gif"));
		fixedDeck.add(new Ace(11, "Clubs", 1, img));

		img = ImageIO.read(new File("Images\\d2.gif"));
		fixedDeck.add(new Card(2, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d3.gif"));
		fixedDeck.add(new Card(3, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d4.gif"));
		fixedDeck.add(new Card(4, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d5.gif"));
		fixedDeck.add(new Card(5, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d6.gif"));
		fixedDeck.add(new Card(6, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d7.gif"));
		fixedDeck.add(new Card(7, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d8.gif"));
		fixedDeck.add(new Card(8, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d9.gif"));
		fixedDeck.add(new Card(9, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d10.gif"));
		fixedDeck.add(new Card(10, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\dj.gif"));
		fixedDeck.add(new Jack(10, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\dq.gif"));
		fixedDeck.add(new Queen(10, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\dk.gif"));
		fixedDeck.add(new King(10, "Diamonds", 1, img));
		img = ImageIO.read(new File("Images\\d1.gif"));
		fixedDeck.add(new Ace(11, "Diamonds", 1, img));

		img = ImageIO.read(new File("Images\\h2.gif"));
		fixedDeck.add(new Card(2, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h3.gif"));
		fixedDeck.add(new Card(3, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h4.gif"));
		fixedDeck.add(new Card(4, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h5.gif"));
		fixedDeck.add(new Card(5, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h6.gif"));
		fixedDeck.add(new Card(6, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h7.gif"));
		fixedDeck.add(new Card(7, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h8.gif"));
		fixedDeck.add(new Card(8, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h9.gif"));
		fixedDeck.add(new Card(9, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h10.gif"));
		fixedDeck.add(new Card(10, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\hj.gif"));
		fixedDeck.add(new Jack(10, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\hq.gif"));
		fixedDeck.add(new Queen(10, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\hk.gif"));
		fixedDeck.add(new King(10, "Hearts", 1, img));
		img = ImageIO.read(new File("Images\\h1.gif"));
		fixedDeck.add(new Ace(11, "Hearts", 1, img));

		img = ImageIO.read(new File("Images\\s2.gif"));
		fixedDeck.add(new Card(2, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s3.gif"));
		fixedDeck.add(new Card(3, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s4.gif"));
		fixedDeck.add(new Card(4, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s5.gif"));
		fixedDeck.add(new Card(5, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s6.gif"));
		fixedDeck.add(new Card(6, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s7.gif"));
		fixedDeck.add(new Card(7, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s8.gif"));
		fixedDeck.add(new Card(8, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s9.gif"));
		fixedDeck.add(new Card(9, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s10.gif"));
		fixedDeck.add(new Card(10, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\sj.gif"));
		fixedDeck.add(new Jack(10, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\sq.gif"));
		fixedDeck.add(new Queen(10, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\sk.gif"));
		fixedDeck.add(new King(10, "Spades", 1, img));
		img = ImageIO.read(new File("Images\\s1.gif"));
		fixedDeck.add(new Ace(11, "Spades", 1, img));
	}

}
